#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    bool findTargetIn2DPlants(vector<vector<int>>& plants, int target)
    {
        if (plants.empty()) return false;
        int n = plants.size(), m = plants[0].size();
        int line = 0, row = m - 1;
        while (line >= 0 && line < n && row >= 0 && row < m)
        {
            if (plants[line][row] < target)
            {
                ++line;
            }
            else if (plants[line][row] > target)
            {
                --row;
            }
            else
            {
                return true;
            }
        }
        return false;

    }
};